#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#include "cc3.h"

#include "image_proc.h"



int main(void) {
  int i;

  cc3_uart_init (0,
		 CC3_UART_RATE_115200,
		 CC3_UART_MODE_8N1,
		 CC3_UART_BINMODE_TEXT);

  cc3_camera_init ();

  // ready camera
  cc3_camera_set_auto_exposure (true);
  cc3_camera_set_auto_white_balance (true);
  cc3_camera_set_resolution(CC3_CAMERA_RESOLUTION_HIGH);
  cc3_camera_set_colorspace(CC3_COLORSPACE_YCRCB);
  //cc3_camera_set_colorspace(CC3_COLORSPACE_RGB);
  cc3_timer_wait_ms(1000);

  // init
  cc3_led_set_state(0, false);
  cc3_led_set_state(2, true);
  i = 0;
  while(true) {
    
    printf("Ready to go... waiting the button\n");
    while(!cc3_button_get_state());
    printf("Go\n");

	  i++;
    if (i%2==0) {
      cc3_led_set_state (2, true);
    } else {
      cc3_led_set_state (2, false);
    }
    compute_frm(i);
  }

  return 0;
}


